Conditions | 2 |
Paths | 5 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | const util = require('../util') |
||
7 | Kits.list = function (callback) { |
||
8 | if (Kits.cache.length) { |
||
9 | callback(Kits.cache) |
||
10 | return |
||
11 | } |
||
12 | |||
13 | var stopSpinner = util.output.wait('Loading available starter kits') |
||
14 | util.request('kits/short').end(function (response) { |
||
15 | if (response.error || !response.body) { |
||
16 | stopSpinner(response.error) |
||
17 | process.exit() |
||
18 | } |
||
19 | |||
20 | stopSpinner() |
||
21 | var list = response.body.data.sort(function (a, b) { |
||
22 | if (a === 'basic') { |
||
23 | return -1 |
||
24 | } |
||
25 | if (b === 'basic') { |
||
26 | return 1 |
||
27 | } |
||
28 | return a > b ? 1 : -1 |
||
29 | }) |
||
30 | |||
31 | Kits.cache = list |
||
32 | callback(list) |
||
33 | }) |
||
34 | } |
||
35 | |||
37 |